<template>
	<view>
		<recommend :dataList="goodsList" :loading="loading" bottoms="100" v-if="goodsList.length > 0"></recommend>
		<view class="nocart" v-else>
			<text class="iconfont icon-gouwuche1" :style="'color:' + colors"></text>
			<view>没有找到，<text :style="'color:' + colors" @tap="call">问问客服？</text></view>
		</view>
	</view>
</template>

<script>
	var app = getApp();
	import recommend from '../../commponent/home/recommend.vue';
	import goodsApi from '@/api/goods.js'
	export default {
		data() {
			return {
				colors: '',
				goodsName: '',
				goodsList: [],
				loading: true,
				merchant: {
					service: {
						phone: ''
					}
				}
			}
		},
		components: {
			recommend
		},
		onLoad(options) {
			const self = this;
			this.goodsName = options.name;
			this.initData();
			uni.getStorage({
				key: 'c_merchant',
				success(res) {
					self.merchant = res.data.merchant;
				}
			})
		},
		onShow() {
			this.setData({
				colors: app.globalData.newColor,
				current: '99999'
			});
		},
		methods: {
			call() {
				const self = this;
				uni.makePhoneCall({
				    phoneNumber: this.merchant.service.phone
				});
			},
			initData() {
				goodsApi.find({
					name: this.goodsName
				}).then(res => {
					this.goodsList = res.data.data;
				}).finally(() => {
					this.loading = false;
				});
			}
		} 
	}
</script>

<style scoped>
.nocart {
		text-align: center;
		margin-top: 30vh;
	}

	.nocart .iconfont {
		font-size: 80rpx;
		text-align: center;
	}

	.nocart view {
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: #999;
		margin-top: 20rpx;
	}
</style>
